-module(recordtest).
-export([geneuserinfo/1,geneuserinfo/3]).

-record(user, {	uid,
		sex,
		age,
		stage,
		wherefrom,
		startnum=1
	       }).

geneuserinfo([]) ->
    #user{uid=100};
geneuserinfo(Cookies) ->
    geneuserinfo(#user{},Cookies,1).

geneuserinfo(#user{}=User,[],_N) ->
    User;
geneuserinfo(#user{}=User,[Head|Rest],Nth)->
    case Nth of
	1 ->
	    geneuserinfo(User#user{uid=Head}, Rest, Nth+1);
	2 ->
	    geneuserinfo(User#user{sex=Head}, Rest, Nth+1);
	3 ->
	    geneuserinfo(User#user{age=Head}, Rest, Nth+1);
	4 ->
	    geneuserinfo(User#user{stage=Head}, Rest, Nth+1)
    end.



    
